---@class IBaseView : LuaObject
---@field protected super IBaseView
---@field protected obj UnityEngine.GameObject
---@field protected behaviour IBehaviour
local this = BaseClass("IBaseView")

function this:__ctor()
    self.isOpen = false
    self.uniqueId = 0
    self.behaviour = nil
    self.obj = nil
end

---@param agrs table
function this:Init(agrs)
    self.uniqueId = agrs[1]
    self.behaviour = agrs[2]
end

---@return boolean
function this:IsUpdate()
    if (not self.obj) then
        return false
    end
    return self.isOpen
end

--- 脚本挂载事件 (创建时调用，可用于绑定对象)
---@param obj UnityEngine.GameObject
function this:Awake(obj)
    if (self.behaviour and obj) then
        self.behaviour:Awake(obj)
    end

    LuaObjMgr:AddLuaView(self)
    self.obj = obj; self.isOpen = false
end

--- 脚本销毁事件
function this:Destroy()
    if (self.behaviour) then
        self.behaviour:Destroy()
    end

    LuaObjMgr:RemoveLuaView(self)
    self.obj = nil
end

function this:Open()
    self.isOpen = true
end

function this:Close()
    self.isOpen = false
end

IBaseView = this